#!/usr/bin/perl
#save_datetime.cgi

require './datetime-lib.pl';

&ReadParse();
&error_setup($text{'settime_error'});

$in{'day'} = "0".$in{'day'} if ($in{'day'} <= 9);
$in{'month'} = "0".$in{'month'} if ($in{'month'} <= 9);
$in{'hour'} = "0".$in{'hour'} if ($in{'hour'} <= 9);
$in{'minute'} = "0".$in{'minute'} if ($in{'minute'} <= 9);
$in{'second'} = "0".$in{'second'} if ($in{'second'} <= 9);

$format = $in{'month'}.$in{'day'}.$in{'hour'}.$in{'minute'}.$in{'year'}.".".$in{'second'};
`echo yes|date $format`||(&nas_syslog("datetime", "naslog_warning", 35501, "Chnage date/time failed!"), &error($text{'invalid_format'}));
`hwclock --systohc`;
&nas_syslog("datetime", "naslog_info", 35500, "Change date/time success!");

`rm -f $config{'zonelink'}`;
if ($in{'zone'} ne "")
{
	$zone = $config{'zonedir'}."/".$in{'zone'};
	`ln -s $zone $config{'zonelink'}`;
	`echo $in{'zone'} >/sysvol/etc/timezone`;
}
&nas_syslog("datetime", "naslog_info", 35502, "Change time zone success!");

&redirect("");
